<?php
$path_root = $_SERVER['DOCUMENT_ROOT'];

require_once($path_root."/AppSaleOnline/model/application.php");

$obj_app = new Applications();

$data = $obj_app->getListApplications();

$top_1_download = $obj_app->find_app_has_number_download_max(); // tim ung dung co so lan tai ve cao nhat

echo "<table border='0' class='table table-striped'>";
echo "<thead>";
    echo "<th>Tên ứng dụng</th>";
    echo "<th>Tên file</th>";
    echo "<th>Lượt tải</th>";
echo "</thead>";
foreach($data as $key=>$value)
{
    echo "<tr>";
        $app_name = $value['app_name'];
        echo "<td>".$value['app_name']."</td>";
        echo "<td>".$value['app_path']."</td>";
        echo "<td>".$value['count_dl']."</td>";
        echo "<td><input type=\"button\" class='btn-default btn btn-sm' value='Chi tiết download' onclick=\"list_user_download('$app_name')\"/></td>";
    echo "</tr>";
}   
echo "<tr><td colspan='4'><p> Ứng dụng có số lượt tải cao nhất là"." <font color=\"green\"><b><i>". $top_1_download[1]."<i></b></font> với lượt tải là: ".$top_1_download[8]."</p></td></tr>";
echo "</table>";


